using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Snake_and_Ladders
{
    class Program
    {
        static void Main(string[] args)
        {
            int dice = 1; 
            int boardSquare = 100;
            int playerPosition = 1;
            string answer = "yes";

            //Rules
            Console.WriteLine("Rules: \n1. The Board counts 100 squares and when you arrive on 100 you will win.\n2. You must roll the dice." +
               "\n3. You start from position 1.\n4. You will move forward with the number indicate on the dice.\n5. If you find a ledder you will go on the top of it" +
                "\n6. If you find a snake you will go down on the tail of it.");
            Console.WriteLine("Ladders-------------------------Snakes");
            Console.WriteLine("3->12---------------------------30->8");
            Console.WriteLine("9->21---------------------------46->22");
            Console.WriteLine("14->36--------------------------55->13");
            Console.WriteLine("20->88--------------------------69->49");
            Console.WriteLine("35->56--------------------------74->34");
            Console.WriteLine("48->62--------------------------79->57");
            Console.WriteLine("60->91--------------------------83->68");
            Console.WriteLine("72->81--------------------------99->2\n");



            Console.Write("Start the game?  ");
            answer = Console.ReadLine();
            while (answer.Equals("Yes", StringComparison.InvariantCultureIgnoreCase) && playerPosition<101)
            {
                Random rnd = new Random();
                dice = rnd.Next(1, 7);
                Console.WriteLine("The dice shows:{0} ", dice);
                playerPosition += dice;
                Console.WriteLine("Your position is:{0}",playerPosition);
                Console.WriteLine("--------------------------------------------------------------");
                Console.Write("Roll Dices?  ");
                answer = Console.ReadLine();
                if (playerPosition >= 100) 
                {
                    Console.WriteLine("Congratulation!!! You Won!!.");
                }
                else if (playerPosition == 3)
                {
                    playerPosition += 9;
                    Console.WriteLine("Good Luck!Advance 9 squares until position 12");
                }
                else if (playerPosition == 9)
                {
                    playerPosition += 12;
                    Console.WriteLine("Good Luck!Advance 12 squares until position 21");
                }
                else if (playerPosition == 14)
                {
                    playerPosition += 22;
                    Console.WriteLine("Good Luck!Advance 22 squares until position 36");
                }
                else if (playerPosition == 20)
                {
                    playerPosition += 68;
                    Console.WriteLine("Good Luck!Advance 68 squares until position 88");
                }
                else if (playerPosition == 35)
                {
                    playerPosition += 21;
                    Console.WriteLine("Good Luck!Advance 21 squares until position 56");
                }
                else if (playerPosition == 48)
                {
                    playerPosition += 14;
                    Console.WriteLine("Good Luck!Advance 14 squares until position 62");
                }
                else if (playerPosition == 60)
                {
                    playerPosition += 31;
                    Console.WriteLine("Good Luck!Advance 31 squares until position 91");
                }
                else if (playerPosition == 72)
                {
                    playerPosition += 9;
                    Console.WriteLine("Good Luck!Advance 9 squares until position 81");
                }
                else if (playerPosition == 30)
                {
                    playerPosition -= 22;
                    Console.WriteLine("Bad Luck!Reverse 22 squares until position 8 ");
                }
                else if (playerPosition == 46)
                {
                    playerPosition -= 24;
                    Console.WriteLine("Bad Luck!Reverse 24 squares until position 22 ");
                }
                else if (playerPosition == 55)
                {
                    playerPosition -= 42;
                    Console.WriteLine("Bad Luck!Reverse 42 squares until position 13 ");
                }
                else if (playerPosition == 69)
                {
                    playerPosition -= 20;
                    Console.WriteLine("Bad Luck!Reverse 20 squares until position 49 ");
                }
                else if (playerPosition == 74)
                {
                    playerPosition -= 40;
                    Console.WriteLine("Bad Luck!Reverse 40 squares until position 34 ");
                }
                else if (playerPosition == 79)
                {
                    playerPosition -= 22;
                    Console.WriteLine("Bad Luck!Reverse 22 squares until position 57 ");
                }
                else if (playerPosition == 83)
                {
                    playerPosition -= 15;
                    Console.WriteLine("Bad Luck!Reverse 15 squares until position 68");
                }
                else if (playerPosition == 99)
                {
                    playerPosition -= 97;
                    Console.WriteLine("Bad Luck!Reverse 97 squares until position 2");
                }
            }
        }
    }
}
